from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.wait import WebDriverWait

from part import LogInFace
from Driver.Driver import MDriver
class test1:
    Log=''
    def __init__(self):
        self.Log=LogInFace.LogInFace()
    # 检测界面元素
    def LogFace(self):
        self.Log.Come()
        self.Log.Face()
        MDriver.photo()


    # 登陆函数
    def LogIn(self,name,Pass):
        self.Log.LogInScanfName(name)
        self.Log.LogInScanfPass(Pass)
        self.Log.LogInTake()
        MDriver.photo()
    # 清空函数
    def Delete(self):
        self.Log.DeleteName()
        self.Log.DeletePass()
    # 正常登陆
    def LogInSccess(self):
        self.LogIn("zhang","12345")
        WebDriverWait(MDriver.driver,3).until(expected_conditions.presence_of_element_located((By.CSS_SELECTOR,"#article_list_board_title")))
        MDriver.photo()



    # 可能正常登陆
    def LogInMaybeSccess(self):
        # 正确的用户名后有空白字符，正确的密码
        self.LogIn("zhang ", "12345")
        WebDriverWait(MDriver.driver,3).until(expected_conditions.presence_of_element_located((By.CSS_SELECTOR,"#article_list_board_title")))
        MDriver.photo()



    # 异常登陆
    def LogInMaybeFalse(self):
        # 正确的用户名，错误的密码
        self.LogIn("zhangsan","12345678")
        self.Delete()
        # 正确的用户名，无密码
        self.LogIn("zhangsan","")
        self.Delete()
        # 错误的用户名，正确的密码
        self.LogIn("zhan","1234")
        self.Delete()
        # 错误的用户名，错误的密码
        self.LogIn("zhan","1234567")
        self.Delete()
        # 错误的用户名，无密码
        self.LogIn("zhan","")
        self.Delete()
        # 无用户名，正确的密码
        self.LogIn("","1234")
        self.Delete()
        # 无用户名，错误的密码
        self.LogIn("","123")
        self.Delete()
        # 无用户名，无密码
        self.LogIn("","")
        self.Delete()
        # 正确的用户名后有空白字符，无密码
        self.LogIn("zhangsan    ","")
        self.Delete()
        # 正确的用户名后有空白字符，错误的密码
        self.LogIn("zhangsan  ", "1234567")
        self.Delete()


